import { request } from "./request"
// 商品列表商品分类网络请求



//获取商品列表数据
export function getgoods(query, pagenum, pagesize) {
    return request({
        url: "goods",
        method: "get",
        params: {
            query,
            pagenum,
            pagesize
        }
    })
}




//商品数据列表 放入级联选择器中
export function getcategories() {
    return request({
        url: "/categories",
        method: "get",
        params: {
            type: 3
        }
    })
}

//获取级联选择器第三级的动态参数
export function getcategoriesmany(id) {
    return request({
        url: `categories/${id}/attributes`,
        method: "get",
        params: {
            sel: "many"
        }
    })
}

//获取级联选择器第三级的静态参数
export function getcategoriesonly(id) {
    return request({
        url: `categories/${id}/attributes`,
        method: "get",
        params: {
            sel: "only"
        }
    })
}

//发送添加商品的网络请求
export function addgoods(form) {
    return request({
        url: "/goods",
        method: "post",
        data: {
            goods_name: form.goods_name,
            goods_cat: form.goods_cat,
            goods_price: form.goods_price,
            goods_number: form.goods_number,
            goods_weight: form.goods_weight,
            goods_introduce: form.goods_introduce,
            pics: form.pics,
            attrs: form.attrs
        }
    })
}

// 编辑动态提交参数
export function deletecategories(id, attrId, deleteform) {
    return request({
        url: `categories/${id}/attributes/${attrId}`,
        method: "put",
        data: {
            attr_name: deleteform.attr_name,
            attr_sel: deleteform.attr_sel,
            attr_vals: deleteform.attr_vals
        }
    })
}

//添加动态参数的属性值网络请求
export function addcategories(id, attrId, deleteform) {
    return request({
        url: `categories/${id}/attributes/${attrId}`,
        method: "put",
        data: {
            attr_name: deleteform.attr_name,
            attr_sel: deleteform.attr_sel,
            attr_vals: deleteform.attr_vals
        }
    })
}

//添加动态参数的按钮网络请求
export function addpush(id, pushform) {
    return request({
        url: `categories/${id}/attributes`,
        method: "post",
        data: {
            attr_name: pushform.attr_name,
            attr_sel: pushform.attr_sel,
            attr_vals: pushform.attr_vals
        }
    })
}

// 删除动态参数
export function deleteattrid(id, attrid) {
    return request({
        url: `categories/${id}/attributes/${attrid}`,
        method: "delete",
    })
}

//添加静态参数的按钮网络请求
export function addpushonly(id, onlyform) {
    return request({
        url: `categories/${id}/attributes`,
        method: "post",
        data: {
            attr_name: onlyform.attr_name,
            attr_sel: onlyform.attr_sel,
            attr_vals: onlyform.attr_vals
        }
    })
}

// 删除静态参数
export function deleteattridonly(id, attrid) {
    return request({
        url: `categories/${id}/attributes/${attrid}`,
        method: "delete",
    })
}

// 修改静态参数名称
export function reviseonly(id, attrid, reviseform) {
    return request({
        url: `categories/${id}/attributes/${attrid}`,
        method: "put",
        data: {
            attr_name: reviseform.attr_name,
            attr_sel: reviseform.attr_sel,
            attr_vals: reviseform.attr_vals
        }
    })
}


// 修改动态态参数名称
export function revisemany(id, attrid, reviseform) {
    return request({
        url: `categories/${id}/attributes/${attrid}`,
        method: "put",
        data: {
            attr_name: reviseform.attr_name,
            attr_sel: reviseform.attr_sel,
            attr_vals: reviseform.attr_vals
        }
    })
}